#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<string.h>
char* replaceSpaces(char* S, int length) {
    char str[500001];
    int i = 0;
    char copy[4] = "%20";
    char* p = S;
    while (length--)
    {
        if (*p == ' ')
        {
            int num = 3;
            for (int j = 0; j < num; j++)
            {
                str[i++] = copy[j];
            }
        }
        else
        {
            str[i++] = *p;
        }
        p++;
    }
    return str;
}
int main()
{
    char str[100];
    strcpy(str, "Mr John Smith    ");
    char*ret=replaceSpaces(str, 13);
    printf("%s", ret);
    return 0;
}